package com.apes.fn.rpt.profit;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/***
 * 毛利报表
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = GrossProfit.CONST_TABLE_NAME)
public class GrossProfit extends BaseModel {
    public static final String CONST_TABLE_NAME = "rpt_gross_profit";


    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "毛利报表", prefix = "1")
    @Comment("流水编号")
    private String id;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id")
    @Comment("公司编码")
    private PartyRole company;


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dept_id", referencedColumnName = "id", nullable = false)
    @Comment("部门编码")
    private Dept dept;


    @Column(name = "income_categories")
    @Comment("收入大类")
    private String incomeCategories;


    @Column(name = "type", length = 255)
    @Comment("项目")
    private String type;

    @Column(name = "times", nullable = false, columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("台次")
    private double times = 0;

    @Column(name = "amt_sale", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("营业额")
    private double amtSale = 0;

    @Column(name = "UN_BILL_AMOUNT", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("待记账金额")
    private double unBillAmount = 0;

    @Column(name = "BILL_AMOUNT", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("记账金额")
    private double billAmount = 0;



    @Column(name = "amt_cost", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("成本")
    private double amtCost = 0;

    @Column(name = "ACCESSORY_COST", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("配件成本")
    private double accessoryCost = 0;


    @Column(name = "MAN_HOUR_COST", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("工时成本")
    private double manHourCost = 0;


    @Column(name = "amt_material_cost", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("耗材成本")
    private double amtMaterialCost = 0;

    @Column(name = "supply_chain_management_fee", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("供应链管理费")
    private double supplyChainManagementFee = 0;

    @Column(name = "platform_management_fee", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("平台管理费")
    private double platformManagementFee = 0;

    @Column(name = "cross_company_income", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("会员联盟结算-收入")
    private double crossCompanyIncome = 0;

    @Column(name = "cross_company_pay", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("会员联盟结算-支出")
    private double crossCompanyPay = 0;

    @Column(name = "amt_profit", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("毛利")
    private double amtProfit = 0;

    @Column(name = "profit_rate", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("毛利率")
    private double profitRate = 0;

    @Comment("统计日期")
    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Column(name = "statistics_date")
    private Date statisticsDate;
}
